package thread.state;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: 线程的新建、运行和终止状态
 * @date 2022/10/29 20:27
 */
public class NewAndRunnableState {
    public static void main(String[] args) {
        // 产生一个线程对象，该对象默认的状态就是新建状态 - NEW
        Thread t = new Thread(() -> {
            for (int i = 0; i < 1000_0000; i++) {}
        },"子线程");
        System.out.println(t.getName() + " : " + t.getState());
        t.start();
        while (t.isAlive()) {
            System.out.println(t.getName() + " : " + t.getState());
        }
        System.out.println(t.getName() + " : " + t.getState());
    }
}